##cmake_minimum_required( VERSION 2.8 )
project("tscore")
find_package( Qt4 REQUIRED )
include( ${QT_USE_FILE} )
INCLUDE_DIRECTORIES(
    ${QT_INCLUDE_DIR}
    ${QT_QTSQL_INCLUDE_DIR}
    ${CMAKE_CURRENT_BINARY_DIR}
    interfaces

)

# генерируем деф файл
#check_include_file_cxx("src/def.h" HAVE_DEF)
set(INSTPREF ${CMAKE_INSTALL_PREFIX})
configure_file(def.h.in def.h)



set( tscore_H
        tslog.h
        tsiniter.h
        mainwin.h
)

set( tscore_SRCS
        main.cpp
        tslog.cpp
        tsiniter.cpp
        mainwin.cpp
)
set( UIS
    mainwin.ui
)


qt4_wrap_ui(UIS_H ${UIS})

qt4_wrap_cpp( MOC_SOURCES ${tscore_H} )

set( RESOURCES res.qrc )
qt4_add_resources( QRC_SOURCES ${RESOURCES} )

add_executable( tscore ${tscore_SRCS} ${MOC_SOURCES} ${UIS_H} ${QRC_SOURCES})

target_link_libraries( tscore ${QT_LIBRARIES} ${QT_QTSQL_LIBRARIES})

# install for linux
if(${CMAKE_SYSTEM_NAME} STREQUAL Linux)
    set(tsdir ${CMAKE_INSTALL_PREFIX})
    set(tsdir_bin ${tsdir}/bin)
    install(TARGETS tscore DESTINATION ${tsdir_bin})
    install(FILES files/tscore.ini
    DESTINATION ${tsdir}/etc )
    install(FILES files/torisakura_splash_logo.png DESTINATION ${tsdir}/share/pixmaps)
    install(FILES files/torisakura_login_logo.png DESTINATION ${tsdir}/share/pixmaps)
endif()
# install for mac os x
if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin)
    set(tsdir ${CMAKE_INSTALL_PREFIX})
    set(tsdir_bin ${tsdir}/bin)
    install(TARGETS tscore DESTINATION ${tsdir_bin})
    install(FILES files/tscore.ini
    DESTINATION ${tsdir}/etc )
    install(FILES files/torisakura_splash_logo.png DESTINATION ${tsdir}/share/pixmaps)
    install(FILES files/torisakura_login_logo.png DESTINATION ${tsdir}/share/pixmaps)
endif()

#for windows not install. cpack.


